home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- +
- + LEDA 2.1.1 11-15-1991
- +
- +
- + window.h
- +
- +
- + Copyright (c) 1991 by Max-Planck-Institut fuer Informatik
- + Im Stadtwald, 6600 Saarbruecken, FRG
- + All rights reserved.
- +
- *******************************************************************************/
-
-
- #ifndef WINDOW_H
- #define WINDOW_H
-
- #include <LEDA/basic.h>
- #include <LEDA/plane.h>
-
- declare(list,string)
-
-
- typedef double (*draw_func_ptr) (double);
- typedef void (*redraw_func_ptr) ();
- typedef void (*mouse_action_func_ptr) (double,double);
-
- enum color { white=0,
- black=1,
- red=2,
- green=3,
- blue=4,
- yellow=5,
- violet=6,
- orange=7
- };
-
- enum line_style {solid, dashed, dotted};
- enum text_mode {transparent, opaque};
- enum drawing_mode {src_mode, xor_mode};
-
-
- extern const int SCREEN_WIDTH;
- extern const int SCREEN_HEIGHT;
-
- class window {
-
- int state;
- list(string) mesg_list;
-
- public:
-
- window(float width, float height, float xpos, float ypos);
- window(float width = SCREEN_HEIGHT-20, float height = SCREEN_HEIGHT);
- ~window();
-
- void init(double x0,double x1,double y0,int gmode = 0);
-
- operator int() { return state; }
-
-
- void set_redraw(redraw_func_ptr f);
- bool set_font(char* s);
- void set_grid_mode(int i);
- line_style set_line_style(line_style s) ;
- int set_line_width(int w);
- drawing_mode set_mode(drawing_mode m);
- int set_node_width(int w);
- text_mode set_text_mode(text_mode m);
- void set_frame_label(string s);
- void set_flush(bool b);
-
-
- int get_line_width();
- int get_node_width();
- line_style get_line_style();
- text_mode get_text_mode();
- drawing_mode get_mode();
- int mono();
-
- double xmin();
- double xmax();
- double ymin();
- double ymax();
- double scale();
-
- int xpix(double x);
- int ypix(double x);
-
- double pixnum(int p);
-
- // flushing window
-
- void flush();
-
-
- // drawing segments
-
- void draw_segment(double x1, double y1, double x2, double y2, color c = black );
- void draw_segment(point p, point q, color c = black );
- void draw_segment(segment s, color c = black );
-
-
- // drawing lines
-
- void draw_line(double x1, double y1, double x2, double y2, color c = black );
- void draw_line(point p, point q, color c=black) ;
- void draw_line(line l, color c=black);
- void draw_hline(double y, color c = black );
- void draw_vline(double x, color c = black );
-
-
- // drawing arrows
-
- void draw_arrow(double x1, double y1, double x2, double y2, color c = black );
- void draw_arrow(point p, point q, color c = black );
- void draw_arrow(segment s, color c = black );
-
- // drawing edges
-
- void draw_edge(double x1, double y1, double x2, double y2, color c = black );
- void draw_edge(point p, point q, color c = black );
- void draw_edge(segment s, color c = black );
-
- void draw_edge_arrow(double x1, double y1, double x2, double y2, color c = black );
- void draw_edge_arrow(point p, point q, color c = black );
- void draw_edge_arrow(segment s, color c = black );
-
-
-
- // drawing a single pixel
-
- void draw_pix(double x, double y, color c = black );
- void draw_pix(point p, color c = black );
-
-
-
- // drawing points
-
- void draw_point(double x0,double y0,color c = black);
- void draw_point(point p,color c = black);
-
-
-
- // drawing nodes
-
- void draw_node(double x0,double y0,color c = black) ;
- void draw_node(point p, color c = black);
- void draw_filled_node(double x0,double y0,color c = black);
- void draw_filled_node(point p, color c = black);
- void draw_text_node(double x,double y,string s,color c = black);
- void draw_text_node(point p ,string s,color c = black);
- void draw_int_node(double x,double y,int i,color c = black);
- void draw_int_node(point p ,int i,color c = black);
-
-
- //circles
-
- void draw_circle(double x,double y,double r,color c = black);
- void draw_circle(point p,double r,color c = black);
- void draw_circle(circle C,color c = black);
-
- void draw_disc(double x,double y,double r,color c = black);
- void draw_disc(point p,double r,color c = black);
- void draw_disc(circle C,color c = black);
-
- //ellipses
-
- void draw_ellipse(double x,double y,double a, double b, color c = black);
- void draw_ellipse(point p, double a, double b, color c = black);
-
-
- //drawing polygons
-
- void draw_polygon(list(point) lp, color c = black );
- void draw_polygon(polygon P, color c = black );
- void draw_filled_polygon(list(point) lp, color c = black );
- void draw_filled_polygon(polygon P,color c = black );
-
-
- void draw_rectangle(double a, double b, double c, double d, color col = black);
- void draw_filled_rectangle(double a, double b, double c, double d, color col = black);
-
-
- // miscellaneous
- void copy_rect(double x1, double y1, double x2, double y2, double x, double y) ;
- void move_rect(double x1, double y1, double x2, double y2, double x, double y) ;
- void copy(double x1, double y1, double x2, double y2, int i=0) ;
- void cut(double x1, double y1, double x2, double y2, int i=0) ;
- void paste(int i, double x, double y);
- void paste(double x, double y);
- void clear_buf(int i=0);
-
- void clear(color c = white);
- void show_window();
-
-
- // text
-
- void draw_text(double x, double y, string s, color c = black);
- void draw_text(point p, string s, color c = black);
- void draw_ctext(double x, double y, string s, color c = black);
- void draw_ctext(point p, string s, color c = black);
-
-
-
-
- // drawing functions
-
- void plot_xy(double x0, double x1, draw_func_ptr f, color c = black);
- void plot_yx(double y0, double y1, draw_func_ptr f, color c = black);
-
-
-
- // mouse input
-
- int read_mouse();
-
- int read_mouse(real&, real&);
- int read_mouse(point&);
-
- int read_mouse_seg(double, double, real&, real&);
- int read_mouse_seg(point, point&);
-
- int read_mouse_rect(double, double, real&, real&);
- int read_mouse_rect(point, point&);
-
- int read_mouse_circle(double, double, real&, real&);
- int read_mouse_circle(point, point&);
-
- int read_mouse_action(mouse_action_func_ptr, real&, real&);
- int read_mouse_action(mouse_action_func_ptr, point&);
-
-
- // overloaded read and draw functions
-
- window& read(point&);
- window& read(segment&);
- window& read(line&);
- window& read(polygon&);
- window& read(circle&);
-
- window& draw(point p, color c = black);
- window& draw(segment s, color c = black);
- window& draw(line l, color c=black);
- window& draw(circle C,color c = black);
- window& draw(polygon P, color c = black );
-
-
- int confirm(string s);
- void acknowledge(string s);
- void notice(string s);
-
- int read_panel(string, int, string*);
- int read_vpanel(string, int, string*);
-
- string read_string(string,string,list(string)&);
- string read_string(string,list(string)&);
- string read_string(string);
-
- real read_real(string);
-
- int read_int(string);
-
- //------------------------------------------------------------------------------
- // input operators
- //------------------------------------------------------------------------------
-
- window& operator>>(point&);
- window& operator>>(segment&);
- window& operator>>(line&);
- window& operator>>(circle&);
- window& operator>>(polygon&);
-
- //------------------------------------------------------------------------------
- // output
- //------------------------------------------------------------------------------
-
- window& operator<<(point p) { draw(p); return *this; }
- window& operator<<(segment s) { draw(s); return *this; }
- window& operator<<(line l) { draw(l); return *this; }
- window& operator<<(circle C) { draw(C); return *this; }
- window& operator<<(polygon P) { draw(P); return *this; }
-
-
- void message(string);
- void del_message();
-
- void add_message(string);
- void clear_messages();
- void show_message();
-
- }; // end of class window
-
-
-
- #ifndef __TURBOC__
-
- //------------------------------------------------------------------------------
- // PANELS
- //------------------------------------------------------------------------------
-
- struct panel {
-
- void* panel_ptr;
-
- panel();
- panel(string s);
- ~panel();
-
-
- void label(string s);
- void text_item(string s);
-
- void string_item(string s, string& x);
- void string_item(string label,string& x,list(string)& L);
-
- void choice_item(string header,int& x,int n,string* L);
- void choice_item(string header,int& x,list(string)& L);
- void choice_item(string header,int& x,string,string);
- void choice_item(string header,int& x,string,string,string);
- void choice_item(string header,int& x,string,string,string,string);
- void choice_item(string header,int& x,string,string,string,string,string);
-
- void int_item(string s,int& x);
- void int_item(string s,int& x, int l, int h, int step);
- void int_item(string s,int& x, int l, int h);
-
- void bool_item(string s, int& x);
- void real_item(string s, real& x);
- void double_item(string s, double& x);
-
- void color_item(string s, color& x);
-
- void button(string s);
- void button(int i,int l=1);
-
- void new_button_line();
- void new_button_line(int,string*);
- void new_button_line(list(string)&);
-
-
- int open();
-
- int open(int n, string* buttons) { new_button_line(n,buttons); return open();}
-
- int open(list(string) buttons) { new_button_line(buttons); return open(); }
-
- };
-
- #endif
-
- #endif
-